home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / brent_cc.lha / brent_cc / math_num.h < prev    next >
C/C++ Source or Header  |  1993-08-08  |  2KB  |  81 lines

  1. // This may look like C code, but it is really -*- C++ -*-
  2. /*
  3.  ************************************************************************
  4.  *
  5.  *              Numerical Math Package
  6.  *
  7.  * The present package implements various algorithms of Numerical Math
  8.  *
  9.  ************************************************************************
  10.  */
  11.  
  12. #pragma once
  13. #pragma interface
  14.  
  15. #include "myenv.h"
  16. #include <math.h>
  17. #include <std.h>
  18.  
  19. /*
  20.  *------------------------------------------------------------------------
  21.  *                Some constants
  22.  * Compile and run the program epsilon.c to determine the values below for
  23.  * your computer
  24.  */
  25.  
  26. #define EPSILON        2.22045e-16
  27. #define SQRT_EPSILON    1.49012e-08
  28.  
  29. /*
  30.  *------------------------------------------------------------------------
  31.  *        Brent's minimum and zero finders for 
  32.  *          a function of a single argument
  33.  */
  34.  
  35.                 // Obtain a zero of function f
  36.                 // over the range [ax,bx] with the
  37.                 // accuracy tol.
  38. double zeroin(const double ax, const double bx, 
  39.           double (*f)(const double x), const double tol=EPSILON);
  40.  
  41.                 // Find a minimum of function f
  42.                 // over the range [a,b] with the
  43.                 // accuracy tol.
  44.                 // Returns an approx. to the min location
  45. double fminbr(const double a, const double b, 
  46.           double (*f)(const double x), const double tol=EPSILON);
  47.  
  48. #ifdef REAL
  49.  
  50. /*
  51.  *------------------------------------------------------------------------
  52.  *            Interpolation of the function
  53.  *            specified in the tabular form
  54.  */
  55.  
  56.                 // Aitken-Lagrange interpolation to the
  57.                 // point q over the table of function values
  58.                 // y[i] = y(x[i]), i = y.lwb..y.upb
  59. overload ali;
  60.                 // Uniform mesh x[i] = x0 + s*(i-y.lwb)
  61. double ali(const double q, const double x0, const double s, const Vector& y);
  62.                 // Nonuniform grid with nodes in x[i]
  63. double ali(const double q, const Vector& x, const Vector& y);
  64.  
  65. /*
  66.  *------------------------------------------------------------------------
  67.  *            Multi-dimensional minimization
  68.  */
  69.  
  70.                 // Find a local minimum of a given
  71.                 // function by the Hook-Jeevse method
  72. double hjmin(                // Return the function value at min
  73.     Vector& b,            // On input - initial guess to min loc
  74.                     // On output - loc for the min found
  75.      const Vector& h0,        // Initial values for the steps along
  76.                      // each direction
  77.      double (*f)(const Vector& x)    // Procedure to compute a function
  78.                      // value at the specified point
  79.         );
  80. #endif
  81.